home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / TableColumn.java < prev    next >
Text File  |  1998-06-30  |  21KB  |  649 lines

  1. /*
  2.  * @(#)TableColumn.java    1.26 98/04/07
  3.  *
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  *
  19.  */
  20.  
  21. package com.sun.java.swing.table;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.border.*;
  25. import java.lang.Integer;
  26. import java.awt.Color;
  27. import java.awt.Component;
  28. import java.io.Serializable;
  29. import java.beans.PropertyChangeEvent;
  30. import java.beans.PropertyChangeListener;
  31.  
  32. /**
  33.  *  A <B>TableColumn</B> represents all the attributes of a column in a
  34.  *  <B>JTable</B>, such as width, resizibility, minimum and maximum width.
  35.  *  In addition, the <B>TableColumn</B> also helps to determine how the JTable
  36.  *  interprets and displays the value objects from the TableModel in
  37.  *  the column.  This is done using the cellRenderer of the column.  For
  38.  *  example, the TableModel can give the table Boolean objects
  39.  *  for a column.  If the column's cellRenderer is a <B>JCheckBox</B>
  40.  *  component then the table will be able
  41.  *  to show the Boolean value as a checkbox.  If the column's
  42.  *  cellEditor is set similarly the user will then be able to modify the cell
  43.  *  value using a <B>JCheckBox</B>. This pairing of source's value object with
  44.  *  cell renders and editors gives the table a great deal of power and flexibility.
  45.  *  Because the table does not need to know anything about the data being
  46.  *  displayed, the user is free to customize it.
  47.  *  <p>
  48.  *  The TableColumn stores the link between the columns in the <B>JTable</B>
  49.  *  and the columns in the <B>TableModel</B>. This, the <I>modelIndex</I>, is the
  50.  *  column in the TableModel which will be queried for the data values for the
  51.  *  cells in this column. As the column moves around in the view this
  52.  *  <I>modelIndex</I> does not change.
  53.  *  <p>
  54.  *  It is also possible to specify renderers and editors on a per type basis
  55.  *  rather than a per column basis - see the <I>setDefaultRenderer()</I> method
  56.  *  in the <B>JTable</B>. This default mechanism is only used when the renderer (or
  57.  *  editor) in the <B>TableColumn</B> is <I>null</I>.
  58.  * <p>
  59.  * Warning: serialized objects of this class will not be compatible with
  60.  * future swing releases.  The current serialization support is appropriate
  61.  * for short term storage or RMI between Swing1.0 applications.  It will
  62.  * not be possible to load serialized Swing1.0 objects with future releases
  63.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  64.  * baseline for the serialized form of Swing objects.
  65.  *
  66.  * @version 1.26 04/07/98
  67.  * @author Alan Chung
  68.  * @author Philip Milne
  69.  * @see TableColumnModel
  70.  * @see DefaultTableColumnModel
  71.  */
  72. public class TableColumn extends Object implements Serializable {
  73. //
  74. // Static Constants
  75. //
  76.  
  77.     /** Bound property name. */
  78.     public final static String COLUMN_WIDTH_PROPERTY = "columWidth";
  79.     /** Bound property name. */
  80.     public final static String HEADER_VALUE_PROPERTY = "headerValue";
  81.     /** Bound property name. */
  82.     public final static String HEADER_RENDERER_PROPERTY = "headerRenderer";
  83.     /** Bound property name. */
  84.     public final static String CELL_RENDERER_PROPERTY = "cellRenderer";
  85.  
  86. //
  87. //  Instance Variables
  88. //
  89.  
  90.     /**
  91.       * The index of the column in the model which is to be displayed by
  92.       * this TableColumn. As columns are moved around in the view the
  93.       * model index remains constant.
  94.       */
  95.     protected int    modelIndex;
  96.  
  97.     /**
  98.      *  This object is not used internally by the drawing machinery of
  99.      *  the JTable. Identifiers may be set in the TableColumn as as an
  100.      *  optional way to tag and locate TableColumns. The table package does
  101.      *  not modify or invoke any methods in these identifer objects other
  102.      *  than the <I>equals</I> method which is used in the
  103.      *  <I>getColumnIndex()</I> method in the <B>DefaultTableColumnModel</B>.
  104.      */
  105.     protected Object    identifier;
  106.  
  107.     /** The width of the column */
  108.     protected int    width;
  109.  
  110.     /** The minimum width of the column */
  111.     protected int    minWidth;
  112.  
  113.     /** The maximum width of the column */
  114.     protected int    maxWidth;
  115.  
  116.     /** The renderer used to draw the header of the column */
  117.     protected TableCellRenderer    headerRenderer;
  118.  
  119.     /** The header value of the column */
  120.     protected Object        headerValue;
  121.  
  122.     /** The renderer used to draw the data cells of the column */
  123.     protected TableCellRenderer    cellRenderer;
  124.  
  125.     /** The editor used to edit the data cells of the column */
  126.     protected TableCellEditor    cellEditor;
  127.  
  128.     /** Resizable flag */
  129.     protected boolean    isResizable;
  130.  
  131.     /**
  132.      *  Counter used to disable posting of resizing notifications until the
  133.      *  end of the resize
  134.      */
  135.     transient protected int    resizedPostingDisableCount;
  136.  
  137.     /**
  138.      * If any PropertyChangeListeners have been registered, the
  139.      * changeSupport field describes them.
  140.      */
  141.     private java.beans.PropertyChangeSupport changeSupport;
  142.  
  143. //
  144. // Constructors
  145. //
  146.  
  147.     /**
  148.      * Creates an empty <B>TableColumn</B>. This is intended for the use
  149.      * of the serialization code.  <p>
  150.      *
  151.      */
  152.     public TableColumn() {
  153.     this(0);
  154.     }
  155.  
  156.     /**
  157.      *  Creates and initializes an instance of <B>TableColumn</B> with
  158.      *  <I>modelIndex</I>.
  159.      *  The <I>modelIndex</I> is the index of the column in the model which
  160.      *  will supply the data for this column in the table. This, like the
  161.      *  <I>columnIdentifier</I> in previous releases, does not change as the
  162.      *  columns are moved in the view.
  163.      *  <p>
  164.      *
  165.      * @param    modelIndex    the column in the model which provides the values for this column
  166.      * @see #setHeaderValue()
  167.      */
  168.     public TableColumn(int modelIndex) {
  169.     this(modelIndex, 75, null, null);
  170.     }
  171.  
  172.     public TableColumn(int modelIndex, int width) {
  173.     this(modelIndex, width, null, null);
  174.     }
  175.  
  176.     public TableColumn(int modelIndex, int width,
  177.                  TableCellRenderer cellRenderer,
  178.                  TableCellEditor cellEditor) {
  179.     super();
  180.     this.modelIndex = modelIndex;
  181.     this.width = width;
  182.     this.cellRenderer = cellRenderer;
  183.     this.cellEditor = cellEditor;
  184.  
  185.     // Set other instance variables to default values.
  186.     minWidth = 15;
  187.     maxWidth = Integer.MAX_VALUE;
  188.     isResizable = true;
  189.     resizedPostingDisableCount = 0;
  190.     setHeaderRenderer(createDefaultHeaderRenderer());
  191.     headerValue = null;
  192.     }
  193.  
  194. //
  195. // Modifying and Querying attributes
  196. //
  197.  
  198.     /**
  199.      * Sets the model index for this column. The model index is the
  200.      * index of the column in the model that will be displayed by this
  201.      * TableColumn. As the TableColumn is moved around in the view
  202.      * the model index remains constant.
  203.      */
  204.     public void setModelIndex(int anIndex)
  205.     {
  206.     modelIndex = anIndex;
  207.     }
  208.  
  209.     /**
  210.      * Gets the model index for this column.
  211.      */
  212.     public int getModelIndex()
  213.     {
  214.     return modelIndex;
  215.     }
  216.  
  217.     /**
  218.      * Sets the <B>TableColumn</B>'s identifier to <I>anIdentifier</I>.
  219.      * Note identifiers are not used by the JTable, they are purely a
  220.      * convenience for the external tagging and location of columns.
  221.      *
  222.      * @param       anIdentifier        an identifier for this column
  223.      * @see       #getIdentifier()
  224.      */
  225.     public void setIdentifier(Object anIdentifier)
  226.     {
  227.     identifier = anIdentifier;
  228.     }
  229.  
  230.  
  231.     /**
  232.      *  Returns the identifier object for this column. Note identifiers are not
  233.      *  used by the JTable, they are purely a convenience for external use.
  234.      *  If the identifier is <I>null</I> <I>getIdentifier()</I> returns
  235.      *  <code>getHeaderValue()</code> as a default.
  236.      *
  237.      * @return    the idenitifer object for this column
  238.      * @see    #setIdentifier()
  239.      */
  240.     public Object getIdentifier()
  241.     {
  242.         return (identifier != null) ? identifier : getHeaderValue();
  243.  
  244.     }
  245.  
  246.     /**
  247.      * Sets the <B>TableCellRenderer</B> used to draw the <B>TableColumn's</B>
  248.      * header to <I>aRenderer</I>.  Posts a bound property change notification
  249.      * with the name HEADER_RENDERER_PROPERTY.
  250.      *
  251.      * @exception IllegalArgumentException    if <I>aRenderer</I> is null.
  252.      * @param      aRenderer            the new header renderer
  253.      * @see      #getHeaderRenderer()
  254.      */
  255.     public void setHeaderRenderer(TableCellRenderer aRenderer)
  256.     {
  257.     TableCellRenderer oldRenderer = headerRenderer;
  258.  
  259.     if (aRenderer == null) {
  260.         throw new IllegalArgumentException("Object is null");
  261.     }
  262.     headerRenderer = aRenderer;
  263.  
  264.     // Post header renderer changed event notification
  265.     if (changeSupport != null) {
  266.         changeSupport.firePropertyChange(HEADER_RENDERER_PROPERTY,
  267.                          oldRenderer, headerRenderer);
  268.     }
  269.     }
  270.  
  271.     /**
  272.      * Returns the <B>TableCellRenderer</B> used to draw the header of the
  273.      * <B>TableColumn</B>. The default header renderer is a
  274.      * <B>JCellRenderer</B> initialized with a <B>JLabel</B>.
  275.      *
  276.      * @return    the <B>TableCellRenderer</B> used to draw the header
  277.      * @see    #setHeaderRenderer()
  278.      * @see    #setHeaderValue()
  279.      */
  280.     public TableCellRenderer getHeaderRenderer()
  281.     {
  282.     return headerRenderer;
  283.     }
  284.  
  285.     /**
  286.      * Sets the <B>Object</B> used as the value for the headerRenderer
  287.      * Posts a bound property change notification with the name
  288.      * HEADER_VALUE_PROPERTY.
  289.      *
  290.      * @param      aValue            the new header value
  291.      * @see      #getHeaderValue()
  292.      */
  293.     public void setHeaderValue(Object aValue)
  294.     {
  295.     Object oldValue = headerValue;
  296.  
  297.     headerValue = aValue;
  298.  
  299.     // Post header value changed event notification
  300.     if (changeSupport != null) {
  301.         changeSupport.firePropertyChange(HEADER_VALUE_PROPERTY,
  302.                          oldValue, headerValue);
  303.     }
  304.     }
  305.  
  306.     /**
  307.      * Returns the <B>Object</B> used as the value for the header renderer.
  308.      *
  309.      * @return    the <B>Object</B> used as the value for the header renderer
  310.      * @see    #setHeaderValue()
  311.      */
  312.     public Object getHeaderValue() {
  313.     return headerValue;
  314.     }
  315.  
  316.     /**
  317.      * Sets the <B>TableCellRenderer</B> used by <B>JTable</B> to draw
  318.      * individual values for this column to <I>aRenderer</I>.  Posts a
  319.      * bound property change notification with the name CELL_RENDERER_PROPERTY.
  320.      *
  321.      * @param    aRenderer            the new data cell renderer
  322.      * @see    #getCellRenderer()
  323.      */
  324.     public void setCellRenderer(TableCellRenderer aRenderer)
  325.     {
  326.     TableCellRenderer oldRenderer = cellRenderer;
  327.  
  328.     cellRenderer = aRenderer;
  329.  
  330.     // Post cell renderer changed event notification
  331.     if (changeSupport != null) {
  332.         changeSupport.firePropertyChange(CELL_RENDERER_PROPERTY,
  333.                          oldRenderer, cellRenderer);
  334.     }
  335.     }
  336.  
  337.     /**
  338.      * Returns the <B>TableCellRenderer</B> used by the <B>JTable</B> to draw
  339.      * values for this column.  The <I>cellRenderer</I> of the column not
  340.      * only controls the visual look for the column, but is also used to
  341.      * interpret the value object supplied by the TableModel.  The
  342.      * default <I>cellRenderer</I> is a <B>JCellRenderer</B>
  343.      * initialized with a <B>JLabel</B>.
  344.      *
  345.      * @return    the <B>TableCellRenderer</B> used by the <B>JTable</B> to
  346.      *         draw values for this column
  347.      * @see    #setCellRenderer()
  348.      */
  349.     public TableCellRenderer getCellRenderer()
  350.     {
  351.     return cellRenderer;
  352.     }
  353.  
  354.     /**
  355.      * Sets the <B>TableCellEditor</B> used by <B>JTable</B> to draw individual
  356.      * values for this column to <I>anEditor</I>.  A <B>null</B> editor
  357.      * means the column is not editable.
  358.      *
  359.      * @param    anEditor            the new data cell editor
  360.      * @see    #getCellEditor()
  361.      */
  362.     public void setCellEditor(TableCellEditor anEditor)
  363.     {
  364.     cellEditor = anEditor;
  365.     }
  366.  
  367.     /**
  368.      * Returns the <B>TableCellEditor</B> used by the <B>JTable</B> to draw
  369.      * values for this column.  The <I>cellEditor</I> of the column not
  370.      * only controls the visual look for the column, but is also used to
  371.      * interpret the value object supplied by the TableModel.  The
  372.      * default <I>cellEditor</I> is null.
  373.      *
  374.      * @return    the <B>TableCellEditor</B> used by the <B>JTable</B> to
  375.      *         draw values for this column
  376.      * @see    #setCellEditor()
  377.      */
  378.     public TableCellEditor getCellEditor()
  379.     {
  380.     return cellEditor;
  381.     }
  382.  
  383.     /**
  384.      * Sets this column's width to <I>newWidth</I>.  If <I>newWidth</I>
  385.      * exceeds the minimum or maximum width, it's adjusted to the
  386.      * appropriate limiting value. Posts a bound property
  387.      * change notification with the name COLUMN_WIDTH_PROPERTY.
  388.      * <p>
  389.      * Note: The default resize mode of the JTable is AUTO_RESIZE_ALL_COLUMNS,
  390.      * which causes the JTable to control the widths of the columns itself
  391.      * and so override any widths set by an application using this method.
  392.      * To control the widths of the columns progammatically, be
  393.      * sure to first call setAutoResizeMode(AUTO_RESIZE_OFF) on the JTable.
  394.      *
  395.      * @param    newWidth        The new width value
  396.      * @see    #getWidth()
  397.      * @see    #getMinWidth()
  398.      * @see    #setMinWidth()
  399.      * @see    #getMaxWidth()
  400.      * @see    #setMaxWidth()
  401.      */
  402.     public void setWidth(int newWidth)
  403.     {
  404.     int oldWidth = width;
  405.  
  406.     // Do a quick check
  407.     if (width == newWidth)
  408.         return;
  409.  
  410.     // Set the width, and check min & max
  411.     width = newWidth;
  412.     if (width < minWidth)
  413.         width = minWidth;
  414.     else if (width > maxWidth)
  415.         width = maxWidth;
  416.  
  417.     // Post resize event notification
  418.     if (changeSupport != null) {
  419.         changeSupport.firePropertyChange(COLUMN_WIDTH_PROPERTY,
  420.                        new Integer(oldWidth), new Integer(width));
  421.     }
  422.     }
  423.  
  424.     /**
  425.      * Returns the width of the <B>TableColumn</B>. The default width is
  426.      * 75.
  427.      *
  428.      * @return    the width of the <B>TableColumn</B>
  429.      * @see    #setWidth()
  430.      * @see    #getMinWidth()
  431.      * @see    #setMinWidth()
  432.      * @see    #getMaxWidth()
  433.      * @see    #setMaxWidth()
  434.      */
  435.     public int getWidth()
  436.     {
  437.     return width;
  438.     }
  439.  
  440.     /**
  441.      * Sets the <B>TableColumn's</B> minimum width to <I>newMinWidth</I>,
  442.      * also adjusting the current width if it's less than this value.
  443.      *
  444.      * @param    newMinWidth        the new minimum width value
  445.      * @see    #getWidth()
  446.      * @see    #setWidth()
  447.      * @see    #getMinWidth()
  448.      * @see    #getMaxWidth()
  449.      * @see    #setMaxWidth()
  450.      */
  451.     public void setMinWidth(int newMinWidth)
  452.     {
  453.     minWidth = newMinWidth;
  454.     if (minWidth < 0)
  455.         minWidth = 0;
  456.  
  457.     if (width < minWidth)
  458.         this.setWidth(minWidth);
  459.     }
  460.  
  461.     /**
  462.      * Returns the minimum width for the <B>TableColumn</B>. The
  463.      * <B>TableColumn's</B> width can't be made less than this either
  464.      * by the user or programmatically.  The default minWidth is 15.
  465.      *
  466.      * @return    the minimum width for the <B>TableColumn</B>
  467.      * @see    #getWidth()
  468.      * @see    #setWidth()
  469.      * @see    #setMinWidth()
  470.      * @see    #getMaxWidth()
  471.      * @see    #setMaxWidth()
  472.      */
  473.     public int getMinWidth()
  474.     {
  475.     return minWidth;
  476.     }
  477.  
  478.     /**
  479.      * Sets the <B>TableColumn's</B> maximum width to <I>newMaxWidth</I>,
  480.      * also adjusting the current width if it's greater than this value.
  481.      *
  482.      * @param    newMaxWidth        the new maximum width value
  483.      * @see    #getWidth()
  484.      * @see    #setWidth()
  485.      * @see    #getMinWidth()
  486.      * @see    #setMinWidth()
  487.      * @see    #getMaxWidth()
  488.      */
  489.     public void setMaxWidth(int newMaxWidth)
  490.     {
  491.     maxWidth = newMaxWidth;
  492.     if (maxWidth < 0)
  493.         maxWidth = 0;
  494.     else if (maxWidth < minWidth)
  495.         maxWidth = minWidth;
  496.  
  497.     if (width > maxWidth)
  498.         this.setWidth(maxWidth);
  499.     }
  500.  
  501.     /**
  502.      * Returns the maximum width for the <B>TableColumn</B>. The
  503.      * <B>TableColumn's</B> width can't be made larger than this
  504.      * either by the user or programmatically.  The default maxWidth
  505.      * is 2000.
  506.      *
  507.      * @return    the maximum width for the <B>TableColumn</B>.
  508.      * @see    #getWidth()
  509.      * @see    #setWidth()
  510.      * @see    #getMinWidth()
  511.      * @see    #setMinWidth()
  512.      * @see    #setMaxWidth()
  513.      */
  514.     public int getMaxWidth()
  515.     {
  516.     return maxWidth;
  517.     }
  518.  
  519.     /**
  520.      * Sets whether the user can resize the receiver in its
  521.      * <B>JTableView</B>.
  522.      *
  523.      * @param    flag        true if the column isResizable
  524.      * @see    #getResizable()
  525.      */
  526.     public void setResizable(boolean flag)
  527.     {
  528.     isResizable = flag;
  529.     }
  530.  
  531.     /**
  532.      * Returns true if the user is allowed to resize the <B>TableColumn</B>
  533.      * width, false otherwise. You can change the width programmatically
  534.      * regardless of this setting.  The default is true.
  535.      *
  536.      * @return    true if the user is allowed to resize the <B>TableColumn</B>
  537.      *         width, false otherwise.
  538.      * @see    #setResizable()
  539.      */
  540.     public boolean getResizable()
  541.     {
  542.     return isResizable;
  543.     }
  544.  
  545.     /**
  546.      * Resizes the <B>TableColumn</B> to fit the width of its header cell.
  547.      * If the maximum width is less than the width of the header, the
  548.      * maximum is increased to the header's width. Similarly, if the
  549.      * minimum width is greater than the width of the header, the minimum
  550.      * is reduced to the header's width.
  551.      *
  552.      * @see    #setWidth()
  553.      * @see    #setMinWidth()
  554.      * @see    #setMaxWidth()
  555.      */
  556.     public void sizeWidthToFit() {
  557.     // Get the preferred width of the header
  558.         Component comp;
  559.     comp = this.getHeaderRenderer().getTableCellRendererComponent(null,
  560.                 getHeaderValue(), false, false, 0, 0);
  561.     int headerWidth = comp.getPreferredSize().width;
  562.  
  563.     // Have to adjust the max or min before setting the width
  564.     if (headerWidth > this.getMaxWidth())
  565.         this.setMaxWidth(headerWidth);
  566.     if (headerWidth < this.getMinWidth())
  567.         this.setMinWidth(headerWidth);
  568.  
  569.     // Set the width
  570.     this.setWidth(headerWidth);
  571.     }
  572.  
  573.     public void disableResizedPosting() {
  574.     resizedPostingDisableCount++;
  575.     }
  576.  
  577.     public void enableResizedPosting() {
  578.     resizedPostingDisableCount--;
  579.     }
  580.  
  581. //
  582. // Property Change Support
  583. //
  584.  
  585.     /**
  586.      * Add a PropertyChangeListener to the listener list.
  587.      * The listener is registered for all properties.
  588.      * <p>
  589.      * A PropertyChangeEvent will get fired in response to an
  590.      * explicit setFont, setBackground, or SetForeground on the
  591.      * current component.  Note that if the current component is
  592.      * inheriting its foreground, background, or font from its
  593.      * container, then no event will be fired in response to a
  594.      * change in the inherited property.
  595.      *
  596.      * @param listener  The PropertyChangeListener to be added
  597.      */
  598.  
  599.     public synchronized void addPropertyChangeListener(
  600.                                 PropertyChangeListener listener) {
  601.         if (changeSupport == null) {
  602.             changeSupport = new java.beans.PropertyChangeSupport(this);
  603.         }
  604.         changeSupport.addPropertyChangeListener(listener);
  605.     }
  606.  
  607.     /**
  608.      * Remove a PropertyChangeListener from the listener list.
  609.      * This removes a PropertyChangeListener that was registered
  610.      * for all properties.
  611.      *
  612.      * @param listener  The PropertyChangeListener to be removed
  613.      */
  614.  
  615.     public synchronized void removePropertyChangeListener(
  616.                                 PropertyChangeListener listener) {
  617.         if (changeSupport != null) {
  618.         changeSupport.removePropertyChangeListener(listener);
  619.     }
  620.     }
  621.  
  622. //
  623. // Protected Methods
  624. //
  625.  
  626.     protected TableCellRenderer createDefaultHeaderRenderer() {
  627.     DefaultTableCellRenderer label = new DefaultTableCellRenderer() {
  628.         public Component getTableCellRendererComponent(JTable table, Object value,
  629.                          boolean isSelected, boolean hasFocus, int row, int column) {
  630.             if (table != null) {
  631.                 JTableHeader header = table.getTableHeader();
  632.                 if (header != null) {
  633.                     setForeground(header.getForeground());
  634.                     setBackground(header.getBackground());
  635.                     setFont(header.getFont());
  636.                 }
  637.                 }
  638.  
  639.                 setText((value == null) ? "" : value.toString());
  640.         setBorder(UIManager.getBorder("TableHeader.cellBorder"));
  641.             return this;
  642.             }
  643.     };
  644.     label.setHorizontalAlignment(JLabel.CENTER);
  645.     return label;
  646.     }
  647.  
  648. } // End of class TableColumn
  649.